<?php
require dirname(__FILE__).'/include/common.inc.php';
$webglobal['file_vip'] = array();

if ($webglobal['action'] == 'view') {
	define('PAGESCRIPT', 'vip_view');
} else {
	define('PAGESCRIPT', 'vip');

	$webrequest['page'] = isset($webrequest['page']) ? max(1, intval($webrequest['page'])) : 1;
	$webglobal['file_vip']['perpage'] = 10;
	$webglobal['file_vip']['datanum'] = $db->GetNum("SELECT COUNT(*) FROM {$webconfig['dbpre']}brand_info WHERE `status` = 1");

	$webglobal['file_vip']['dataarray'] = array();
	if ($webglobal['file_checkin']['datanum'] > 0) {
		$option = array(
			'page' => '@@'
		);

		$webglobal['page'] = global_Page($webglobal['file_checkin']['datanum'], $webglobal['file_checkin']['perpage'], $webrequest['page'], buildURLForModule('checkin', $option));
		$tempstartnum = ($webrequest['page']-1)*$webglobal['file_checkin']['perpage'];

		$query = $db->Query("SELECT {$fileSql} FROM `tm_company_comment` LEFT JOIN `tm_company` ON `tm_company_comment`.`company_id` = `tm_company`.`id` LEFT JOIN `tm_user` ON `tm_company_comment`.`user_id` = `tm_user`.`id` WHERE `tm_company_comment`.`status` = '1' ORDER BY `tm_company_comment`.addtime DESC LIMIT $tempstartnum, {$webglobal['file_checkin']['perpage']}");
		while ($tempdata = $db->FetchArray($query)) {
			$tempdata['addtime'] =  !empty($tempdata['addtime']) ? global_FormatTime($tempdata['addtime']) : '';
			$webglobal['file_companyComment'][$tempdata['id']] = $tempdata;
		}
	}
}

template_Display('vip');